package com.yichen.rent.dao;

import com.yichen.rent.pojo.Message;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface MessageDao extends JpaRepository<Message,String>, JpaSpecificationExecutor<Message> {

     @Query(value = "select * from message where from_id = :fromId and to_id = :toId or from_id = :toId and to_id = :fromId order by send_date",nativeQuery = true)
     List<Message> findListByFromAndTo(@Param(value = "fromId") String fromId, @Param(value = "toId") String toId);

}
